import Vue from 'vue';

import 'normalize.css/normalize.css'; // A modern alternative to CSS resets

import App from './App.vue';
import router from './router';
import store from './store';

// 初始化题库
store.commit('QuestionBank/RESET_LIST');
// 监听屏幕尺寸变化
store.dispatch('app/handleMobileOS');
store.dispatch('app/handleAppWidth');
window.addEventListener('resize', () => {
    store.dispatch('app/handleMobileOS');
    store.dispatch('app/handleAppWidth');
});

// 图片组件
import MmvImage from '@/components/MmvImage/index.vue';
Vue.component('MmvImage', MmvImage);

// 按钮组件
import ScaleButton from '@/components/ScaleButton/index.vue';
Vue.component('ScaleButton', ScaleButton);

// 遮罩组件
import MaskView from '@/components/MaskView/index.vue';
Vue.component('MaskView', MaskView);

// utils
import * as utils from '@/utils/index';
for (const key in utils) {
    Vue.prototype[`$${key}`] = utils[key];
}

// filters
import * as filters from '@/utils/filters';
for (const key in filters) {
    Vue.filter(key, filters[key]);
}

Vue.config.productionTip = false;

new Vue({
    router,
    store,
    render: h => h(App),
}).$mount('#app');
